package kyssion.leetcode.num101_150;

import kyssion.leetcode.util.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class code145_后序遍历 {
    public static void main(String[] args) {

    }

    List<Integer> list ;

    public List<Integer> postorderTraversal(TreeNode root) {
        list= new ArrayList<>();
        ans(root);
        return list;
    }

    private void ans(TreeNode root) {
        if(root==null){
            return;
        }

        ans(root.left);
        ans(root.right);
        list.add(root.val);
    }


}
